loadstring(exports.dgs:dgsImportFunction())()
local sw,sh = guiGetScreenSize()
local px,py = sw/1366,sh/768
font = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 20*px )
font2 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 14*px )
font3 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 12*px )
panel_mute = false

addEvent("cmta_admin:gui_warn", true)
addEventHandler("cmta_admin:gui_warn", localPlayer, function(reason,name)
if panel_mute then return end
panel_mute = true
warn_effect = dgsCreateEffect3D(20)
warnsp = dgsCreateScrollPane(450*px,250*py,466*px,268*py,false,false)  
warnimg = dgsCreateImage(0,0,1,1,_,true,warnsp,tocolor(0,0,0,200))  
dgsEffect3DApplyToScrollPane(warn_effect,warnsp)
textwarn = dgsCreateLabel(0*px,25*py,466*px,50*py,"#ff2828⚠️ Otrzymano ostrzeżenie! ⚠️",false,warnimg)
dgsSetFont( textwarn, font )
dgsSetProperty(textwarn,"colorcoded",true)
dgsSetProperty(textwarn,"alignment",{"center","center"})
textwarn2 = dgsCreateLabel(0*px,100*py,466*px,50*py,"#808080Ostrzeżenie nałożone przez: #DD6B20"..name.."\n#808080Powód: #DD6B20"..reason.."",false,warnimg)
dgsSetFont( textwarn2, font2 )
dgsSetProperty(textwarn2,"colorcoded",true)
dgsSetProperty(textwarn2,"alignment",{"center","center"})
warnbutton = dgsCreateButton( 50*px,200*py,366*px,30*py, "Zapoznałem się z treścią ostrzeżenia", false,warnimg,false,false,false,false,false,false,false,tocolor(221,107,32),tocolor(255,40,40),tocolor(255,40,40))
dgsSetFont( warnbutton, font3 )
addEventHandler ( "onDgsMouseClick", getRootElement(), onwarnclick)
showCursor(true)
if isElement(sound) then
else
sound = playSound("warn.mp3")
setSoundVolume(sound, 0.3)
end
end)

function onwarnclick ( btn, state )
	if btn == "left" and state == "down" and panel_mute then
        if source == warnbutton then
            panel_mute = false
            removeEventHandler ( "onDgsMouseClick", getRootElement(), onwarnclick)
            destroyElement(warn_effect)
            destroyElement(warnsp)
            showCursor(false)
        end
	end
end




addCommandHandler("gp",function()
	x,y,z=getElementPosition(localPlayer)
	rx,ry,rz=getElementRotation(localPlayer)
  	p=string.format("%.2f, %.2f, %.2f, %.2f, %.2f, %.2f",x,y,z,rx,ry,rz)
	setClipboard(p)
	outputChatBox(p)
end)

for k,v in ipairs ( getElementsByType ( "object" ) ) do
	if getElementData ( v, "sciana:raportow" ) then
		scianaplaczu = v
	end
	if getElementData(v,"sciana:text") then
		scianatekstu = v
	end
end

local xtext=nil
local gameView={"Logi serwerowe"}
local sx,sy=guiGetScreenSize()

function renderingInfo()
dxDrawRectangle(sx*(258)/1360, sy*(0)/768, sx*(500)/1360, sy*(23)/768, tocolor(0, 0, 0, 195), false)
	dxDrawText(xtext:gsub("#%x%x%x%x%x%x",""), sx*(258+1)/1360, sy*(0+1)/768, sx*(758+1)/1360, sy*(23+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "center", "center", false, true)
	dxDrawText(xtext:gsub("#%x%x%x%x%x%x",""), sx*(258)/1360, sy*(0)/768, sx*(758)/1360, sy*(23)/768, tocolor(255, 0, 0, 255), 1.00, "default", "center", "center", false, true)
end

function renderingInfo2()
dxDrawRectangle(sx*(258)/1360, sy*(0)/768, sx*(500)/1360, sy*(23)/768, tocolor(0, 0, 0, 195), false)
	dxDrawText(xtext:gsub("#%x%x%x%x%x%x",""), sx*(258+1)/1360, sy*(0+1)/768, sx*(758+1)/1360, sy*(23+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "center", "center", false, true)
	dxDrawText(xtext:gsub("#%x%x%x%x%x%x",""), sx*(258)/1360, sy*(0)/768, sx*(758)/1360, sy*(23)/768, tocolor(0, 192, 0, 255), 1.00, "default", "center", "center", false, true)
end

function raporcik()
	if not getElementData(localPlayer,"player:data").admin then return end
	local tt={}
	reportView=getElementData(scianaplaczu,"sciana:raportow")
	for i,c in ipairs(reportView) do
	    testi = i
		if c[1] then table.insert(tt,c[1]) end
	end
	if testi > 1 then
	concat=table.concat(tt, "\n")
	dxDrawText(concat, sx*(1028)/1360, sy*(220)/768, sx*(1344)/1360, sy*(496)/768, tocolor(255, 255, 255, 255), 1, "font19.1", "right", "top", false, false, false, false, false)
	end
end
addEventHandler("onClientRender", root, raporcik)

addEvent("admin:addText", true)
addEventHandler("admin:addText", root, function(text)
	table.insert(gameView, text)	
	if #gameView > 15 then
		table.remove(gameView, 2)
	end
end)
function raporcik2()
	if not getElementData(localPlayer,"player:data").admin_ucho then return end
	local tt={}
	reportView=getElementData(scianatekstu,"sciana:text")
	for i,c in ipairs(reportView) do
		if c[1] then table.insert(tt,c[1]) end
	end
	concat=table.concat(tt, "\n")
	dxDrawText(concat, sx*(10)/1360, sy*(220)/768, sx*(326)/1360, sy*(497)/768, tocolor(255, 255, 255, 255), 1, "font19.1", "left", "top", false, false, false, false, false)
end
addEventHandler("onClientRender", root, raporcik2)

addEvent("admin:rendering", true)
addEventHandler("admin:rendering", root, function(text)
	xtext=text
	if isEventHandlerAdded("onClientRender",root,renderingInfo) then
		removeEventHandler ( "onClientRender", root, renderingInfo)
	end
	addEventHandler("onClientRender", root, renderingInfo)
	setTimer(function()
		removeEventHandler("onClientRender", root, renderingInfo)
	end, 8000, 1)
end)

addEvent("admin:rendering2", true)
addEventHandler("admin:rendering2", root, function(text)
	xtext=text
	if isEventHandlerAdded("onClientRender",root,renderingInfo2) then
		removeEventHandler ( "onClientRender", root, renderingInfo2)
	end
	addEventHandler("onClientRender", root, renderingInfo2)
	setTimer(function()
		removeEventHandler("onClientRender", root, renderingInfo2)
	end, 8000, 1)
end)

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
	if 
		type( sEventName ) == 'string' and 
		isElement( pElementAttachedTo ) and 
		type( func ) == 'function' 
	then
		local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
		if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
			for i, v in ipairs( aAttachedFunctions ) do
				if v == func then
					return true
				end
			end
		end
	end
 
	return false
end